<include file="public/header" />
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>名称
                </label>
                <div class="layui-input-inline">
                    <input type="text"  name="name" value="" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>电话
                </label>
                <div class="layui-input-inline">
                    <input type="text"  name="mobile" value="" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-row show_1" >
                <div class="layui-form-item">
                    <label class="layui-form-label">联创会员等级</label>
                    <div class="layui-input-block" style="width: 300px;" >
                        <select name="level_id" lay-verify="required"  lay-search="" >
                            <option value=""></option>
                            <foreach name="shareholder_level"  item="vo">
                                <option value="{$key}">{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>




<!--            <div class="layui-row show_1" >-->
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">所属门店</label>-->
<!--                    <div class="layui-input-block" style="width: 300px;" >-->
<!--                        <select name="store_id" lay-verify="required"  lay-search="" >-->
<!--                            <option value=""></option>-->
<!--                            <foreach name="stores" item="vo">-->
<!--                                <option value="{$vo.id}">{$vo.name}</option>-->
<!--                            </foreach>-->
<!--                        </select>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item" >
                <div class="layui-input-block">

                    <button type="button"  class="layui-btn" lay-submit=""  lay-filter="addEdit">保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>

    function getaddress(){

        var address = $("input[name='address']").val();

        $.ajax({
            type: "GET",
            // url: "http://api.map.baidu.com/geocoder/v2/?ak=L7eu2mYjXkU5gFrwTICGKQ5I&callback=renderReverse&location=30.080539,103.857565&output=json&pois=1",
            url:"http://api.map.baidu.com/geocoding/v3/?address="+address+"&output=json&ak=HivG7gmGjGEvho94C5ZCrbM8gVuvklu7&callback",

            dataType: "jsonp",
            jsonp: 'callback',
            success: function (json) {
                var result = json.result;

                $("input[name='lat']").val(result.location.lat);
                $("input[name='lng']").val(result.location.lng);

                // var addressComponent = result.addressComponent;
                // alert(result.formatted_address);
                // var address = ['formatted_address', 'province', 'city', 'district', 'street'];
                // address[0] = result.formatted_address;
                // address[1] = addressComponent.province;
                // address[2] = addressComponent.city;
                // address[3] = addressComponent.district;
                // address[4] = addressComponent.street;
            },
            error: function () {
                alert('fail');
            }
        });

    };
    layui.config({
        base: '.././layarea/mods/'
        , version: '1.0'
    });
    layui.use(['form', 'layedit', 'laydate','jquery','upload'], function(){
        var form = layui.form
            ,layer = layui.layer
            , $ = layui.jquery
            , upload = layui.upload
            ,laydate = layui.laydate


        form.on('submit(addEdit)', function(data){
            $.post($('form').attr('action'),data.field,function(data){

                if(data.code == 200){
                    layer.msg(data.msg);
                    // setTimeout(function () {
                    //     window.location.href =data.url
                    // },2000)
                    xadmin.close();
                    xadmin.father_reload();
                }else {
                    layer.msg(data.msg);
                }
            });
            return false;
        });


    });

</script>
</body>

</html>
